home *** CD-ROM | disk | FTP | other *** search
/ United Public Domain Gold 2 / United Public Domain Gold 2.iso / utilities / pu660.dms / pu660.adf / Vmem / memtest.c < prev    next >
C/C++ Source or Header  |  1991-12-19  |  2KB  |  65 lines

  1. /*
  2. ** MEMTEST - test the virtual memory system
  3. **
  4. ** Version 0.1 ©1990 by Edward Hutchins
  5. ** Authors:
  6. **
  7. **    Edward Hutchins: eah1@cec1.wustl.edu
  8. **    Loren Rittle: l-rittle@uiuc.edu
  9. **
  10. ** Revisions:
  11. ** 04/28/90 modified something - LJR.
  12. ** 12/19/91 code released as freeware under the GNU general public license - Ed.
  13. **
  14. **    This program is free software; you can redistribute it and/or modify
  15. **    it under the terms of the GNU General Public License as published by
  16. **    the Free Software Foundation; either version 1, or (at your option)
  17. **    any later version.
  18. **
  19. **    This program is distributed in the hope that it will be useful,
  20. **    but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. **    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  22. **    GNU General Public License for more details.
  23. **
  24. **    You should have received a copy of the GNU General Public License
  25. **    along with this program; if not, write to the Free Software
  26. **    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  27. */
  28.  
  29. #include "vmem.h"
  30.  
  31. #define TEST_SIZE    312500
  32.  
  33. int main (int argc, char *argv[])
  34. {
  35.   char ans[80];
  36.   long *Mem;
  37.   long lCnt;
  38.  
  39.   printf ("Allocating %d bytes of (FAST) memory ", TEST_SIZE*sizeof(long));
  40.   if (!(Mem = (long *)AllocMem (TEST_SIZE*sizeof(long), 0)))
  41.     {
  42.       printf ("\nAllocMem failed!\n");
  43.       exit (5);
  44.     }
  45.   printf ("at address: $%lx\n", Mem);
  46.  
  47.   printf ("Type 'q' <return> to quit, anything else to sweep.\n");
  48.  
  49.   while (strcmp ("q", gets (ans)) != 0)
  50.     {
  51.       printf ("Setting... ");
  52.       for (lCnt = 0; lCnt < TEST_SIZE; ++lCnt) Mem[lCnt] = lCnt;
  53.       printf ("Getting... ");
  54.       for (lCnt = 0; lCnt < TEST_SIZE; lCnt += 2048)
  55.     if (Mem[lCnt] != lCnt)
  56.     {
  57.             printf ("%d = %d\n", lCnt, Mem[lCnt] );
  58.     }
  59.       printf ("Done.\n");
  60.     }
  61.  
  62.   printf ("Freeing memory\n");
  63.   FreeMem (Mem, TEST_SIZE*sizeof(long));
  64. }
  65.